/*************************************************************************
 *                    free                     *
 *************************************************************************
 *************************************************************************
 * Filename	   : table_pat.h
 * Description   : This file is used to TODO
 * Version	   : 1.0
 * History       :
 free 2013-4-15  Create
 *************************************************************************/

#ifndef _TABLE_PAT_H_
#define _TABLE_PAT_H_

/*************************************************************************
 * the structure of a program contained in PAT
 **************************************************************************/
typedef struct stProgram
{
	unsigned int program_number :16;
	unsigned int reserved :3;
	unsigned int PID :13;
	struct stProgram *pstNext;
} PROGRAM;

typedef struct stSectionPat
{
	unsigned int table_id :8;
	unsigned int section_syntax_indicator :1;
	unsigned int reserved_future_use :1;
	unsigned int reserved1 :2;
	unsigned int section_length :12;
	unsigned int transport_stream_id :16;
	unsigned int reserved2 :2;
	unsigned int version_number :5;
	unsigned int current_next_indicator :1;
	unsigned int section_number :8;
	unsigned int last_section_number :8;
	PROGRAM *pstPrograms;
	struct stSectionPat *pstNext;
} SECTION_PAT;

SECTION_PAT *GetTablePat(FILE *pInputFile, long int liFirstPackageOffset, int iPackageLength);
void FreeTablePat(SECTION_PAT **ppstTablePat);

#endif /* TABLE_PAT_H_ */
